package cn.yuanqiao.quartz.task;

import cn.yuanqiao.archive.archiveRelease.service.IArchiveReleaseService;
import cn.yuanqiao.common.utils.DateUtils;
import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.quartz.util.MethodDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component("ReleaseTask")
public class ReleaseTask {

    private static final Logger log = LoggerFactory.getLogger(ReleaseTask.class);

    @Autowired
    private IArchiveReleaseService archiveReleaseService;


    @MethodDescription("定时发布任务，arg0需要传入tenantCode")
    public void task(String tenantCode)
    {
        try {
            if(StringUtils.isNotEmpty(tenantCode)){
                Date start = new Date();
                log.info("定时发布任务开始="+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,start));
                archiveReleaseService.timingTelease(tenantCode);
                Date end = new Date();
                log.info("定时发布任务结束="+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,end));
                log.info("耗时="+(end.getTime()-start.getTime())+"毫秒");
            }else {
                log.error("TenantCode is null");
            }
        }catch (Exception e){
            log.error(e.getMessage(),e);
        }


    }
}
